name: Reviewdog

on:
  pull_request:
    types: [opened, review_requested]

jobs:
  reviewdog:
    runs-on: ubuntu-latest

    if: github.event.action == 'opened' || github.event.requested_team.name == 'reviewdog'

    steps:

    - name: Checkout
      uses: actions/checkout@v4

    - uses: actions/setup-python@v5
      with:
        python-version: 3.8

    - name: Install
      run: |
        python -m pip install -U pip
        pip install --progress-bar off -U .[checking]

    - name: Output installed packages
      run: |
        pip freeze --all
    - name: Output dependency tree
      run: |
        pip install pipdeptree
        pipdeptree

    - name: Apply formatters
      run: |
        black .
        blackdoc .
        isort .

    - name: Reviewdog
      uses: reviewdog/action-suggester@v1
      with:
        tool_name: formatters
